﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;

namespace WebRequest.WebApplication.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";

            return View();
        }

        [HttpGet]
        public ActionResult TestFile()
        {
            var file = Path.Combine(Server.MapPath("~/"), "input.pdf");
            return File(file, MimeMapping.GetMimeMapping("input.pdf"), "input.pdf");
        }

        [HttpHead]
        public ActionResult TestFile2()
        {
            //HttpResponseHeader.ContentLength
            var file = Path.Combine(Server.MapPath("~/"), "input.pdf");
            var fileInfo = new FileInfo(file);
            Response.Headers.Set("Content-Length", fileInfo.Length.ToString("D"));
            return new EmptyResult();
        }

        [HttpPost]
        public ActionResult TestFile1()
        {
            return File("input.pdf", MimeMapping.GetMimeMapping("input.pdf"), "input.pdf");
        }
    }
}
